<template>
  <div class="bigdata-card" :style="{backgroundImage: 'url(' + bgImg + ')'}">
    <div class="count ell">
<!--      {{count}}{{unit}}-->
       <count-to class="count ell" separator="" :decimals="getDecimals(count)" :endVal="count" ></count-to><span class="count">{{unit}}{{units}}</span>
    </div>
    <span class="name">{{title}}</span>
    <img class="mark" :src="mark" />
  </div>
</template>

<script>
export default {
  name: 'BigdataCard',
  props: {
    count: {
      type: Number,
      default: 0,
    },
    unit: {
      type: String,
      default: '',
    },
    units: {
      type: String,
      default: '',
    },
    title: {
      type: String,
      default: '',
    },
    bgImg: {
      type: String,
      default: '',
    },
    mark: {
      type: String,
      default: '',
    }
  },
  data() {
    return {

    };
  },
  created() {

  },
  methods: {
    //保留小数位数
    getDecimals(count){
      let decimals = 0
      if (count){
        //获取数值的小数位数
        let arr = (count+'').split(".")
        if (arr.length == 2){
          decimals = arr[1].length
          console.info(count,decimals)
          }
      }
      return decimals;
    }
  }
};
</script>

<style scoped lang="less">
.bigdata-card{
  width: 100%;
  height: 96px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 16px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  margin-bottom: 12px;
  position: relative;
  .count{
    font-weight: bold;
    font-size: 20px;
    color: #fff;
    width: 80%;
    position: relative;
    top: -3px;
  }
  .name{
    font-size: 12px;
    color: #fff;
    position: relative;
    top: -4px;
  }
  .mark{
    position: absolute;
    right: 17px;
    top: 20px;
  }
}
</style>
